import lombok.val;

import java.util.Stack;

public class MyStack {
    public static void main(String[] args) {
        final Stack<Character> stack = new Stack<>();
        String s = "()[]{}";
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if ( !stack.isEmpty() && (
                 stack.peek() == '(' && c == ')' ||
                 stack.peek() == '[' && c == ']' ||
                 stack.peek() == '{' && c == '}'
                )
            ){
                stack.pop();
            }else {
                if (c == ')' || c == ']' || c == '}')
                    System.out.println(false);
                stack.push(c);
            }
        }
        System.out.println(stack.isEmpty());
    }
}
